package com.rjt.redis.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.rjt.redis.model.UserModel;
import com.rjt.redis.service.UserService;


@Controller
@RequestMapping("redis")
public class UserController {

	@Autowired
	private UserService redisService;
	
	@GetMapping("index")
	public  String index() {
		return "user";
	} 
	
	@PostMapping("add")
	@ResponseBody
	public  String add(String userName,String day) {
		return redisService.add(userName, day);
	} 
	
	@GetMapping("get")
	@ResponseBody
	public  Long get(String userName) {
		return redisService.find(userName);
	} 
	
	@GetMapping("del")
	@ResponseBody
	public  String del(String userName) {
		return redisService.del(userName);
	} 
	
	@GetMapping("findAll")
	@ResponseBody
	public   List<UserModel> findAll() {
		return redisService.findAll();
	} 
}
